package com.xh.bussiness.tiku.bean.dto;

import com.xh.bussiness.tiku.constant.QuestionConstant;
import lombok.Data;

/*
 * @Author daiwei
 * @Description
 * @Date 2019/4/11 17:02
 **/
@Data
public class AnswerResultDto {
    /**
     * 作答是否正确
     */
    private Boolean right=false;
    /**
     * 作答结果（-1未作答，0错误，1正确，2部分正确）
     */
    private Integer result = QuestionConstant.ANSWER_RESULT.UN_ANSWER;

    /**
     * 总空数
     */
    private Integer totalBlankCount=0;

    /**
     * 正确空数
     */
    private Integer totalRightBlankCount=0;

    private Double score;

    public AnswerResultDto(){}

    public AnswerResultDto(Boolean right, Integer result, Integer totalBlankCount, Integer totalRightBlankCount) {
        this.right = right;
        this.result = result;
        this.totalBlankCount = totalBlankCount;
        this.totalRightBlankCount = totalRightBlankCount;
    }


    public AnswerResultDto(Boolean right, Integer result, Integer totalBlankCount, Integer totalRightBlankCount,Double score) {
        this.right = right;
        this.result = result;
        this.totalBlankCount = totalBlankCount;
        this.totalRightBlankCount = totalRightBlankCount;
        this.score = score;
    }


    @Override
    public boolean equals(Object obj) {
        if (obj != null && obj.getClass() == this.getClass()) {
            AnswerResultDto answerResultDto= (AnswerResultDto) obj;
            if(answerResultDto.getRight().equals(this.right)
                    &&answerResultDto.getResult().equals(this.result)
                    &&answerResultDto.getTotalBlankCount().equals(this.totalBlankCount)
                    &&answerResultDto.getTotalRightBlankCount().equals(this.totalRightBlankCount)){
                return true;
            }
        }
        return false;
    }

    @Override
    public int hashCode() {
        StringBuilder sb = new StringBuilder();
        sb.append(this.right);
        sb.append(this.result);
        sb.append(this.totalBlankCount);
        sb.append(this.totalRightBlankCount);
        char[] charArr = sb.toString().toCharArray();
        int hash = 0;

        for(char c : charArr) {
            hash = hash * 131 + c;
        }
        return hash;
    }
}
